<?php
    namespace Home\Model;

    use Think\Model\RelationModel;

    class TopicsModel extends RelationModel
    {
        protected $_link = array(
            /*'Topics' => array(
                'mapping_type' => self::MANY_TO_MANY,
                'class_name' => 'Topics',
                'mapping_name' => 'ptopics',
                'foreign_key' => 'id',
                'relation_foreign_key' => 'pid',
                // 'as_fields' => 'pid:cid,name:pname',
                'relation_table' => 'zhihu_topic_relation' //此处应显式定义中间表名称，且不能使用C函数读取表前缀
            )*/
            'question' => array(
                'mapping_type' => self::HAS_MANY,
                'class_name' => 'question',
                'foreign_key' => 'topic_id',
                'mapping_name' => 'tq',
                'mapping_order' => 'datetime DESC',
                'mapping_limit' => '10',
                // 定义更多的关联属性
            )
        );
    }



